#ifndef DATA_MANAGER_H
#define DATA_MANAGER_H
#include <QSettings>

#ifndef MAPGENERATOR_H
#include "../Grid/mapgenerator.h"
#endif

/// 全局存档 和 地图/设施存档
class Data_Manager
{
    const static QString dbName;
    const static QString dbmap, dbfacility;

protected:
    bool has_game;      // 是否有局内游戏
    int gold_number;    // 金币数量
    int grid_progress;  // 地图的解锁进度 <= 2
    int hub_progress;   // 交付中心解锁进度 <= 1
    int interest_rate_progress; // 开采物获得金币的利率的进度 <= 3
    MapGenerator * map_generator; // 地图生成器
    std::vector<std::vector<QString>> facility_map; //{类型}_{组号}

public:
    Data_Manager();
    void doSave(); // 存档
    void loadSave(); // 读档
    // 加钱
    inline void addGoldNum(int bonus){gold_number+=bonus;}
    // 获得金币数
    inline int getGoldNum(){return gold_number;}
    // 获取地图解锁进度
    inline int getGridProgress() const {return grid_progress;}
    // 获取交付中心解锁进度
    inline int getHubProgress() const {return hub_progress;}
    // 获取开采物获得金币的利率
    inline int getInterestRate() const {
        switch(interest_rate_progress)
        {
        case 0:
            return 2;
        case 1:
            return 3;
        case 2:
            return 4;
        case 3:
        default:
            return 6;
        }
    }
    // 获取地图
    inline std::vector<std::vector<char>>& getGrid() const {
        return map_generator->getGrid();
    }
    friend class GameLogic;
    friend class Shop_Scene;
    friend class MainWindow;
    friend class Game_Scene;
};

#endif // DATA_MANAGER_H
